{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "WETfehTOLC1q",
        "outputId": "88e27703-548c-4294-f8b0-2eb6446f8b84"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Mounted at /content/gdrive\n"
          ]
        }
      ],
      "source": [
        "from google.colab import drive\n",
        "\n",
        "drive.mount('/content/gdrive')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "IlMax5ozLeH8"
      },
      "outputs": [],
      "source": [
        "! unzip \"/content/gdrive/MyDrive/Dataset.zip\" -d \"/content/Dataset\""
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "6QpGpdSlLlBd"
      },
      "outputs": [],
      "source": [
        "!pip install ultralytics\n",
        "from IPython import display\n",
        "display.clear_output()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "2y15FGO7LvkA"
      },
      "outputs": [],
      "source": [
        "from ultralytics import YOLO"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "Q-5WfxvSL4Dm"
      },
      "outputs": [],
      "source": [
        "model = YOLO(\"yolov8n.pt\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "cgtcqd8IMEZB"
      },
      "outputs": [],
      "source": [
        "savePath = '/content/gdrive/MyDrive/Weapons_Detection_Model'\n",
        "fileName = 'WD_Model'"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "umcOEnUUMdvy"
      },
      "outputs": [],
      "source": [
        "results = model.train(data=\"/content/Dataset/data.yaml\", epochs=300, optimizer = \"SGD\", project = savePath, name = fileName, lr0=0.01)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "1IsuPfNFpMhq"
      },
      "source": []
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "D9tXC9E2M3nL"
      },
      "outputs": [],
      "source": [
        "model.val()"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [],
      "metadata": {
        "id": "5CJSWrsyV8Yh"
      }
    }
  ],
  "metadata": {
    "accelerator": "GPU",
    "colab": {
      "gpuType": "T4",
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}